Skip to content

Conversation

@Omswastik-11
Copy link

@Omswastik-11 Omswastik-11 commented Jan 8, 2026

Fixes #1601

added a Create method in FlowAPI for publishing flow but not refactored with old publish . (Needs discussion on this)
Added tests using fake_methods so that we can test without local V2 server . I have tested the FlowsV2 methods (get and exists ) and delete and list were not implemented in V2 server so I skipped them .

@Omswastik-11 Omswastik-11 changed the title [ENH] V1 -> V2 Migration [ENH] V1 -> V2 Migration - Flows (module) Jan 8, 2026
@Omswastik-11 Omswastik-11 marked this pull request as ready for review January 8, 2026 15:09
@geetu040 geetu040 mentioned this pull request Jan 9, 2026
25 tasks
@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 64.95726% with 123 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.57%. Comparing base (c5f68bf) to head (36c22aa).

Files with missing lines Patch % Lines
openml/_api/resources/flows.py 44.89% 54 Missing ⚠️
openml/flows/functions.py 28.57% 25 Missing ⚠️
openml/_api/resources/tasks.py 65.95% 16 Missing ⚠️
openml/_api/http/client.py 82.60% 12 Missing ⚠️
openml/_api/runtime/fallback.py 0.00% 6 Missing ⚠️
openml/_api/runtime/core.py 82.14% 5 Missing ⚠️
openml/_api/resources/datasets.py 77.77% 2 Missing ⚠️
openml/_api/__init__.py 75.00% 1 Missing ⚠️
openml/_api/config.py 96.87% 1 Missing ⚠️
openml/tasks/functions.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1609      +/-   ##
==========================================
- Coverage   53.02%   51.57%   -1.46%     
==========================================
  Files          36       47      +11     
  Lines        4326     4640     +314     
==========================================
+ Hits         2294     2393      +99     
- Misses       2032     2247     +215     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@geetu040 geetu040 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done overall.

Comment on lines +36 to +43
class FlowsAPI(ResourceAPI, ABC):
@abstractmethod
def get(
self,
flow_id: int,
*,
return_response: bool = False,
) -> OpenMLFlow | tuple[OpenMLFlow, Response]: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use return_response, see the other comment

Comment on lines +48 to +56
@abstractmethod
def list_page(
self,
*,
limit: int | None = None,
offset: int | None = None,
tag: str | None = None,
uploader: str | None = None,
) -> pd.DataFrame: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this method list instead of list_page to match other resources

Comment on lines +71 to +78
def list_page(
self,
*,
limit: int | None = None,
offset: int | None = None,
tag: str | None = None,
uploader: str | None = None,
) -> pd.DataFrame:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, it can be refactored with private helper methods in class

Comment on lines +257 to +258
@staticmethod
def _convert_v2_to_v1_format(v2_json: dict[str, Any]) -> dict[str, dict]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a bad idea, we can discuss this, but where is this being used in sdk?

Comment on lines +122 to +136
from openml._api import api_context

xml_file = (
openml.utils._create_cache_directory_for_id(FLOWS_CACHE_DIR_NAME, flow_id) / "flow.xml"
)
flow_xml = openml._api_calls._perform_api_call("flow/%d" % flow_id, request_method="get")
result = api_context.backend.flows.get(flow_id, return_response=True)

with xml_file.open("w", encoding="utf8") as fh:
fh.write(flow_xml)
if isinstance(result, tuple):
flow, response = result
with xml_file.open("w", encoding="utf8") as fh:
fh.write(response.text)
else:
flow = result

return _create_flow_from_xml(flow_xml)
return flow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use return_response here, just remove all the caching related stuff which should leave the function with probably one-line code that calls the api_context.backend.flows.get method

offset=offset,
tag=kwargs.get("tag"),
uploader=kwargs.get("uploader"),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the suggested approach in #1575 (comment) for listing

"post",
data={"name": name, "external_version": external_version},
)
from openml._api import api_context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import this on the top rather than in each function if that doesn't create any problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why skipping these tests? are they because of changes in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! I'll into this in more details but looks good overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] V1 → V2 API Migration - flows

4 participants